<?php

namespace wechat\user;

use wechat\Wx;

class User extends Wx{

//    获得单个用户信息
    public function gerUserInfo(){

        $url = 'https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$this->getAccessToken().'&openid=oqzTd0eDxUHO0wJI1MxiVhflflM0&lang=zh_CN';
        $data = $this->curl($url);
        echo $data;
    }

//    批量获取用户信息
    public function moreUserInfo($post,$lang='zh_CN'){
//        没封装之前
        $url = 'https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token='.$this->getAccessToken();
//        $data = $this->curl($url,$post);
//        echo $data;

//        封装之后
//        print_r($post);
        $user = [];
        foreach ($post as $v){
            $user['user_list'][]=[
              'openid'=>$v,
                'lang'=>$lang
            ];
        }
        $shuju = json_encode($user);
        $data = $this->curl($url,$shuju);
//        echo $data;
        $data = json_decode($data,true);
        if(isset($data['errcode'])){
            return false;
        }else{
            return $data;
        }
    }
}

?>